<template>
  <div class="app">
    1<input type="text" name="" id="" v-focus><br>
    2<input type="text" name="" id="" v-test>
    <p v-color="mycolor">你好啊</p>
    <button @click="mycolor = 'green'">改变颜色</button>
  </div>
</template>

<script>
export default {
  directives: {
    test: {
      inserted(el) {
        el.focus()
      }
    }
  },
  data() {
    return {
      mycolor: 'red'
    }
  }
}

</script>

<style></style>